package kr.or.eclipse.dine.internal;

import kr.or.eclipse.dine.internal.osx.ShowInShellHandlerOSX;
import kr.or.eclipse.dine.internal.win32.ShowInShellHandlerWIN32;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.progress.WorkbenchJob;

/**
 * {@link Constants#CMD_ID_SHOW_IN_SHELL} 커맨드를 실행 환경에 따라 적절한 레이블로 업데이트 합니다. Mac
 * OSX의 경우 "파인더에서 보기" , 윈도우의 경우 "탐색기에서 보기"로 업데이트 됩니다.
 * 
 * @see ShowInShellHandlerOSX
 * @see ShowInShellHandlerWIN32
 * 
 * @author Jeeeyul
 * 
 */
public class UpdateCommandLabelJob extends WorkbenchJob implements IStartup {
    public UpdateCommandLabelJob() {
        super("Update Command Label");
        setSystem(true);
    }

    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
        ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
        commandService.refreshElements(Constants.CMD_ID_SHOW_IN_SHELL, null);
        return Status.OK_STATUS;
    }

    @Override
    public void earlyStartup() {
        new UpdateCommandLabelJob().schedule();
    }

}
